using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
using UnityX;

namespace UnityXEditor
{
    [CanEditMultipleObjects]
    [CustomEditor(typeof(ImageExtrude), true)]
    internal class ImageExtrudeEditor : GraphicEditor
    {
        private SerializedProperty m_Texture;

        private SerializedProperty m_SizeLeft;
        private SerializedProperty m_SizeLeftType;
        private SerializedProperty m_SizeRight;
        private SerializedProperty m_SizeRightType;
        private SerializedProperty m_SizeTop;
        private SerializedProperty m_SizeTopType;
        private SerializedProperty m_SizeBottom;
        private SerializedProperty m_SizeBottomType;

        private SerializedProperty m_UVSizeLeft;
        private SerializedProperty m_UVSizeRight;
        private SerializedProperty m_UVSizeTop;
        private SerializedProperty m_UVSizeBottom;

        protected override void OnEnable()
        {
            base.OnEnable();
            m_Texture = serializedObject.FindProperty("m_Texture");

            m_SizeLeft = serializedObject.FindProperty("m_SizeLeft");
            m_SizeLeftType = serializedObject.FindProperty("m_SizeLeftType");
            m_SizeRight = serializedObject.FindProperty("m_SizeRight");
            m_SizeRightType = serializedObject.FindProperty("m_SizeRightType");
            m_SizeTop = serializedObject.FindProperty("m_SizeTop");
            m_SizeTopType = serializedObject.FindProperty("m_SizeTopType");
            m_SizeBottom = serializedObject.FindProperty("m_SizeBottom");
            m_SizeBottomType = serializedObject.FindProperty("m_SizeBottomType");

            m_UVSizeLeft = serializedObject.FindProperty("m_UVSizeLeft");
            m_UVSizeRight = serializedObject.FindProperty("m_UVSizeRight");
            m_UVSizeTop = serializedObject.FindProperty("m_UVSizeTop");
            m_UVSizeBottom = serializedObject.FindProperty("m_UVSizeBottom");
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.PropertyField(m_Texture);
            AppearanceControlsGUI();
            RaycastControlsGUI();
            MaskableControlsGUI();
            InspectorTool.DrawTypeProperty("左边", m_SizeLeft, m_SizeLeftType);
            InspectorTool.DrawTypeProperty("右边", m_SizeRight, m_SizeRightType);
            InspectorTool.DrawTypeProperty("上边", m_SizeTop, m_SizeTopType);
            InspectorTool.DrawTypeProperty("下边", m_SizeBottom, m_SizeBottomType);
            EditorGUILayout.PropertyField(m_UVSizeLeft, new GUIContent("左边UV"));
            EditorGUILayout.PropertyField(m_UVSizeRight, new GUIContent("右边UV"));
            EditorGUILayout.PropertyField(m_UVSizeTop, new GUIContent("上边UV"));
            EditorGUILayout.PropertyField(m_UVSizeBottom, new GUIContent("下边UV"));
            serializedObject.ApplyModifiedProperties();
        }
    }
}